/*
 * ConfCommsPanel.java
 *
 * Created on 4 de septiembre de 2008, 1:49
 */

package r4p_gui;

import java.util.ArrayList;

/**
 *
 * @author  nemesis
 */
public class ConfCommsPanel extends javax.swing.JPanel {

    /** Creates new form ConfCommsPanel */
    public ConfCommsPanel() {
        initComponents();
    }
    
    public void relanguage(ArrayList<String> lang) {
	//setting the title description:
	this.label_title.setText(lang.get(0));
	
	this.radioButton_bluetooth.setText(lang.get(2));
	this.radioButton_serial.setText(lang.get(3));
	this.radioButton_usb.setText(lang.get(4));
	
	this.bt_checkBox_auth.setText(lang.get(6));
	this.bt_checkBox_encrypt.setText(lang.get(7));
	this.bt_checkBox_master.setText(lang.get(8));
	this.bt_label_remoteDevice.setText(lang.get(9));
	
	this.sp_label_bauds.setText(lang.get(10));
	this.sp_label_port.setText(lang.get(11));
	this.sp_label_parity.setText(lang.get(12));
	this.sp_label_stopBits.setText(lang.get(13));
	this.sp_label_dataBits.setText(lang.get(14));
	
	this.usb_label_port.setText(lang.get(15));
    }
    
    private void bt_enable(boolean b) {
	this.bt_checkBox_auth.setEnabled(b);
	this.bt_checkBox_encrypt.setEnabled(b);
	this.bt_checkBox_master.setEnabled(b);
	this.bt_comboBox_macs.setEnabled(b);
	this.bt_label_remoteDevice.setEnabled(b);
    }
    
    private void sp_enable(boolean b) {
	this.sp_comboBox_bauds.setEnabled(b);
	this.sp_comboBox_dataBits.setEnabled(b);
	this.sp_comboBox_parity.setEnabled(b);
	this.sp_comboBox_port.setEnabled(b);
	this.sp_comboBox_stopBits.setEnabled(b);
	this.sp_label_bauds.setEnabled(b);
	this.sp_label_dataBits.setEnabled(b);
	this.sp_label_parity.setEnabled(b);
	this.sp_label_port.setEnabled(b);
	this.sp_label_stopBits.setEnabled(b);
    }
    
    private void usb_enable(boolean b) {
	this.usb_comboBox_port.setEnabled(b);
	this.usb_label_port.setEnabled(b);
    }
    
    public void getValues() {
	
    }
    
    public void setValues() {
	
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        label_title = new javax.swing.JLabel();
        radioButton_bluetooth = new javax.swing.JRadioButton();
        radioButton_serial = new javax.swing.JRadioButton();
        radioButton_usb = new javax.swing.JRadioButton();
        bt_label_remoteDevice = new javax.swing.JLabel();
        bt_comboBox_macs = new javax.swing.JComboBox();
        bt_checkBox_auth = new javax.swing.JCheckBox();
        bt_checkBox_encrypt = new javax.swing.JCheckBox();
        bt_checkBox_master = new javax.swing.JCheckBox();
        sp_label_port = new javax.swing.JLabel();
        sp_label_bauds = new javax.swing.JLabel();
        sp_label_parity = new javax.swing.JLabel();
        sp_label_dataBits = new javax.swing.JLabel();
        sp_label_stopBits = new javax.swing.JLabel();
        sp_comboBox_port = new javax.swing.JComboBox();
        sp_comboBox_bauds = new javax.swing.JComboBox();
        sp_comboBox_parity = new javax.swing.JComboBox();
        sp_comboBox_dataBits = new javax.swing.JComboBox();
        sp_comboBox_stopBits = new javax.swing.JComboBox();
        usb_label_port = new javax.swing.JLabel();
        usb_comboBox_port = new javax.swing.JComboBox();

        label_title.setFont(new java.awt.Font("DejaVu Sans", 0, 12));
        label_title.setIcon(new javax.swing.ImageIcon("/home/nemesis/NetBeansProjects/R4P_gui/icons/conf-comms.png")); // NOI18N
        label_title.setText("Here you can customize how are communications with R4P stablished");

        buttonGroup1.add(radioButton_bluetooth);
        radioButton_bluetooth.setFont(new java.awt.Font("DejaVu Sans", 1, 12));
        radioButton_bluetooth.setText("Bluetooth");
        radioButton_bluetooth.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                radioButton_bluetoothMouseClicked(evt);
            }
        });

        buttonGroup1.add(radioButton_serial);
        radioButton_serial.setFont(new java.awt.Font("DejaVu Sans", 1, 12));
        radioButton_serial.setText("Serial Port");
        radioButton_serial.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                radioButton_serialMouseClicked(evt);
            }
        });

        buttonGroup1.add(radioButton_usb);
        radioButton_usb.setFont(new java.awt.Font("DejaVu Sans", 1, 12));
        radioButton_usb.setText("USB Port");
        radioButton_usb.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                radioButton_usbMouseClicked(evt);
            }
        });

        bt_label_remoteDevice.setFont(new java.awt.Font("DejaVu Sans", 0, 10));
        bt_label_remoteDevice.setText("Remote Device Address:");

        bt_comboBox_macs.setEditable(true);
        bt_comboBox_macs.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "00:06:66:00:66:AC" }));
        bt_comboBox_macs.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt_comboBox_macsActionPerformed(evt);
            }
        });

        bt_checkBox_auth.setFont(new java.awt.Font("DejaVu Sans", 0, 10));
        bt_checkBox_auth.setText("Authenticate");

        bt_checkBox_encrypt.setFont(new java.awt.Font("DejaVu Sans", 0, 10));
        bt_checkBox_encrypt.setText("Encrypt");

        bt_checkBox_master.setFont(new java.awt.Font("DejaVu Sans", 0, 10));
        bt_checkBox_master.setText("Master");

        sp_label_port.setFont(new java.awt.Font("DejaVu Sans", 0, 10));
        sp_label_port.setText("Port:");

        sp_label_bauds.setFont(new java.awt.Font("DejaVu Sans", 0, 10));
        sp_label_bauds.setText("Bauds:");

        sp_label_parity.setFont(new java.awt.Font("DejaVu Sans", 0, 10));
        sp_label_parity.setText("Parity:");

        sp_label_dataBits.setFont(new java.awt.Font("DejaVu Sans", 0, 10));
        sp_label_dataBits.setText("DataBits:");

        sp_label_stopBits.setFont(new java.awt.Font("DejaVu Sans", 0, 10));
        sp_label_stopBits.setText("StopBits:");

        sp_comboBox_port.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Serial Port" }));

        sp_comboBox_bauds.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "4800", "9600", "14400", "19200", "28800", "38400", "57600", "115200" }));

        sp_comboBox_parity.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Even", "Odd", "None", "Mark", "Space" }));

        sp_comboBox_dataBits.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "5", "6", "7", "8" }));

        sp_comboBox_stopBits.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "3", "2" }));

        usb_label_port.setFont(new java.awt.Font("DejaVu Sans", 0, 10));
        usb_label_port.setText("Port:");

        usb_comboBox_port.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "USB Port" }));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(label_title)
                    .addComponent(radioButton_bluetooth)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(12, 12, 12)
                        .addComponent(usb_label_port)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(usb_comboBox_port, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(radioButton_usb)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(12, 12, 12)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(bt_checkBox_auth)
                                .addGap(18, 18, 18)
                                .addComponent(bt_checkBox_encrypt)
                                .addGap(18, 18, 18)
                                .addComponent(bt_checkBox_master))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(bt_label_remoteDevice)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(bt_comboBox_macs, javax.swing.GroupLayout.PREFERRED_SIZE, 181, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addComponent(radioButton_serial)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(12, 12, 12)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(sp_label_parity)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(sp_comboBox_parity, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(sp_label_port)
                                    .addComponent(sp_label_bauds))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(sp_comboBox_bauds, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(sp_comboBox_port, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(sp_label_stopBits)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(sp_comboBox_stopBits, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(sp_label_dataBits)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(sp_comboBox_dataBits, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(label_title)
                .addGap(18, 18, 18)
                .addComponent(radioButton_bluetooth)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(bt_label_remoteDevice)
                    .addComponent(bt_comboBox_macs, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(bt_checkBox_auth)
                    .addComponent(bt_checkBox_encrypt)
                    .addComponent(bt_checkBox_master))
                .addGap(18, 18, 18)
                .addComponent(radioButton_serial)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(sp_label_port)
                    .addComponent(sp_comboBox_port, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(sp_label_dataBits)
                    .addComponent(sp_comboBox_dataBits, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(sp_label_bauds)
                    .addComponent(sp_comboBox_bauds, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(sp_label_stopBits)
                    .addComponent(sp_comboBox_stopBits, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(sp_label_parity)
                    .addComponent(sp_comboBox_parity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(radioButton_usb)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(usb_label_port)
                    .addComponent(usb_comboBox_port, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

private void radioButton_bluetoothMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_radioButton_bluetoothMouseClicked
    // bluetooth mode selected:
    this.radioButton_serial.setSelected(false);
    this.radioButton_usb.setSelected(false);
    this.bt_enable(true);
    this.sp_enable(false);
    this.usb_enable(false);
}//GEN-LAST:event_radioButton_bluetoothMouseClicked

private void radioButton_serialMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_radioButton_serialMouseClicked
    // serial mode selected:
    this.radioButton_bluetooth.setSelected(false);
    this.radioButton_usb.setSelected(false);
    this.bt_enable(false);
    this.sp_enable(true);
    this.usb_enable(false);
}//GEN-LAST:event_radioButton_serialMouseClicked

private void radioButton_usbMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_radioButton_usbMouseClicked
    // usb mode selected:
    this.radioButton_serial.setSelected(false);
    this.radioButton_bluetooth.setSelected(false);
    this.bt_enable(false);
    this.sp_enable(false);
    this.usb_enable(true);
}//GEN-LAST:event_radioButton_usbMouseClicked

private void bt_comboBox_macsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_comboBox_macsActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_bt_comboBox_macsActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JCheckBox bt_checkBox_auth;
    private javax.swing.JCheckBox bt_checkBox_encrypt;
    private javax.swing.JCheckBox bt_checkBox_master;
    private javax.swing.JComboBox bt_comboBox_macs;
    private javax.swing.JLabel bt_label_remoteDevice;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JLabel label_title;
    private javax.swing.JRadioButton radioButton_bluetooth;
    private javax.swing.JRadioButton radioButton_serial;
    private javax.swing.JRadioButton radioButton_usb;
    private javax.swing.JComboBox sp_comboBox_bauds;
    private javax.swing.JComboBox sp_comboBox_dataBits;
    private javax.swing.JComboBox sp_comboBox_parity;
    private javax.swing.JComboBox sp_comboBox_port;
    private javax.swing.JComboBox sp_comboBox_stopBits;
    private javax.swing.JLabel sp_label_bauds;
    private javax.swing.JLabel sp_label_dataBits;
    private javax.swing.JLabel sp_label_parity;
    private javax.swing.JLabel sp_label_port;
    private javax.swing.JLabel sp_label_stopBits;
    private javax.swing.JComboBox usb_comboBox_port;
    private javax.swing.JLabel usb_label_port;
    // End of variables declaration//GEN-END:variables

}
